/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.att.config;

import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;

/**
 *
 * @author lenovo
 */
public class AndroidProxy {
    
    private static AndroidProxy instance;
    private IDevice device;
    
    static {
        instance = new AndroidProxy();
    }
    
    private AndroidProxy() {
        
    }
    
    public static synchronized AndroidProxy getInstance() {
        return instance;
    }
    
    private void waitForConnect(AndroidDebugBridge adb) throws InterruptedException {
        while (!adb.hasInitialDeviceList()) {
            Thread.sleep(100);
        }
    }
    
    public IDevice getDevice() {
        return device;
    }
    
    public void connection() throws InterruptedException {
        AndroidDebugBridge adb = AndroidDebugBridge.createBridge();
        waitForConnect(adb);
        device = adb.getDevices()[0];
    }
}
